import request from '@/utils/request'

export const GoodsApi = {

    /**
     *  分页
     * @returns
     */
    getPage: (data) => {
        return request({
            url: '/manage/food/goods/getPage',
            data,
            method: 'post'
        })
    },

    /**
     *  公共分页
     * @returns
     */
    getGoodsMainPage: (data) => {
        return request({
            url: '/manage/food/goods/getGoodsMainPage',
            data,
            method: 'post'
        })
    },

    /**
     *  删除
     * @returns
     */
    deleteGoods: (mainGoodsId) => {
        return request({
            url: '/manage/food/goods/deleteGoods',
            params: {mainGoodsId},
            method: 'get'
        })
    },

    /**
     *  修改商品
     * @returns
     */
    updateGoods: (data) => {
        return request({
            url: '/manage/food/goods/updateGoods',
            data,
            method: 'post',
            showLoading: true
        })
    },

    /**
     *  添加商品
     * @returns
     */
    addGoods: (data) => {
        return request({
            url: '/manage/food/goods/addGoods',
            data: data,
            method: 'post'
        })
    },

    /**
     *  获取公共商品详情
     * @returns
     */
    getGoodsMainDetail: (mainGoodsId) => {
        return request({
            url: '/manage/food/goods/getGoodsMainDetail',
            params: {mainGoodsId},
            method: 'get'
        })
    },

    /**
     *  修改上架状态
     * @returns
     */
    updateShelf: (data) => {
        return request({
            url: '/manage/food/goods/updateShelf',
            data,
            method: 'post'
        })
    },

    /**
     *  批量上传商品价格
     * @returns
     */
    batchUpdateGoodsPrice: (data) => {
        return request({
            url: '/manage/food/goods/batchUpdateGoodsPrice',
            data,
            method: 'post',
            headers: {
                'content-type': 'multipart/form-data'
            },
            showLoading: true,
            loadingText: '上传中...'
        })
    },

    /**
     *  修改排序
     * @returns
     */
    updateSort: (data) => {
        return request({
            url: '/manage/food/goods/updateSort',
            data,
            method: 'post'
        })
    },
}
